package com.lyl.projectspringboot.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisConfig {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        // 1、初始化核心插件
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //  2、添加分页插件
        PaginationInnerInterceptor innerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        // 设置分页上限
        innerInterceptor.setMaxLimit(1000L);
        // 将页数上限添加到分页插件
        interceptor.addInnerInterceptor(innerInterceptor);
        return interceptor;
    }
}
